from django.db import models
from django.contrib.auth import get_user_model
OAUser = get_user_model()

# Create your models here.
class AbsentStatusChoices(models.IntegerChoices):
    AUDITING = 1
    PASS = 2
    REJECT = 3

class AbsentType(models.Model):
    name =models.CharField(max_length=100)
    create_time = models.DateTimeField(auto_now_add=True)

class Absent(models.Model):
    #1、标题
    title = models.CharField(max_length=200)
    #2、请假详细内容
    requests_content = models.TextField()
    #3、请假类型
    absent_type = models.ForeignKey(AbsentType,on_delete=models.CASCADE,related_name='absents',related_query_name='absent')
    #4、发起人
    requester = models.ForeignKey(OAUser,on_delete=models.CASCADE,related_name='my_absents',related_query_name='my_absent')
    #5、审批人
    responder = models.ForeignKey(OAUser,on_delete=models.CASCADE,related_name='sub_absents',related_query_name='sub_absent',null=True)
    #6、状态
    status = models.IntegerField(choices=AbsentStatusChoices,default=AbsentStatusChoices.AUDITING)
    #7、请假开始的日期
    start_date = models.DateTimeField()
    #8、请假结束的日期
    end_date = models.DateTimeField()
    #9、请假发起的日期
    create_time = models.DateTimeField(auto_now_add=True)
    #10、审批回复内容
    response_content = models.TextField(blank=True, null=True)

    class Meta:
        ordering = ('-create_time',)